using UnityEngine;
using System.Collections;

public class Minimap : MonoBehaviour {
	
	private enum ZOOM{
		NEAR = 25,
		NORMAL = 50,
		FAR = 75
	}
	private ZOOM currentZoomLevel;
    public Transform target = null;
	
	private Camera minimapCamera;
    static public Minimap instance;
	void Start () {
        instance = this;
		currentZoomLevel = ZOOM.NORMAL;
		minimapCamera = this.GetComponent<Camera>();
		minimapCamera.orthographicSize = (float)currentZoomLevel;
		Debug.Log(minimapCamera.orthographicSize);
	}
	
	// Update is called once per frame
	void Update () {
        if(target != null)
		FollowTarget();
	/*	if (Input.GetKeyDown(KeyCode.B) )
			Zoom(true);
		else if (Input.GetKeyDown(KeyCode.N) )
			Zoom(false);*/
	}
	private void FollowTarget(){
		Vector3 pos = target.transform.position;
		pos.y = 20;
		this.transform.position = pos;
	}
    public void SetTarget(Transform t)
    {
        this.target = t;
    }
	public void Zoom(bool zoomIn){
		if (zoomIn){
			if (currentZoomLevel == ZOOM.FAR)
				currentZoomLevel  = ZOOM.NORMAL;
			else if (currentZoomLevel == ZOOM.NORMAL)
				currentZoomLevel  = ZOOM.NEAR;
		} else{
			if (currentZoomLevel == ZOOM.NEAR)
				currentZoomLevel  = ZOOM.NORMAL;
			else if (currentZoomLevel == ZOOM.NORMAL)
				currentZoomLevel  = ZOOM.FAR;
		}
		minimapCamera.orthographicSize = (float)currentZoomLevel;
	}
}
